package com.bw.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 王钰--WY
 * @create 2023-08-20 20:16
 */
//@Configuration
public class GatewayConfig {

    @Autowired
    private DiscoveryClient discoveryClient;

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("service-route", r -> r.path("/service/**")
                        .filters(f -> f.stripPrefix(1))
                        .uri("lb://service"))
                .build();
    }
}
